<template>
	<view>
		<!-- 日期 -->
		<picker mode="date" :value="date"  @change="riqi" v-if="dat.type == 'date'" :id="dat.num">
			<view class="uni-input">{{date}}</view>
		</picker>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			// const currentDate = this.getDate({format: true})
			return{
				date: "请选择",
			}
		},
		props:['dat'],
		methods: {
			// 日期
			riqi: function(e) {
				console.log(e,888)
				this.date = e.target.value
				this.$emit('w_rq',{
					name:this.date,
					id:e.target.id,
					item:this.dat.item
				})
			},
			getDate:function(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			},
		}
	}
</script>

<style>
	
</style>
